import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_base_plugin/flutter_base_plugin.dart';
import 'package:flutter_base_plugin_example/models/goods_details_model.dart';
import 'package:flutter_base_plugin_example/page/details/goods/vm/goods_details_view_model.dart';
import 'package:flutter_swiper/flutter_swiper.dart';


/// @author:  JoeKai
/// @date 2022/6/27 16:16
/// @explain：

// ignore: camel_case_types
class GoodsDetailsBanner extends BaseStateless<GoodsDetailsViewModel> {
  @override
  Widget buildWidget(BuildContext context) {
    StoreInfo storeInfo = viewModel.data!.storeInfo!;
    return AspectRatio(
      aspectRatio: 1 / 1,
      child: Swiper(
        autoplay: true,
        itemBuilder: (context, index) {
          return InkWell(
            onTap: () {
              // CommonUtils.showToast(index);
            },
            child: Image.network(
              storeInfo.sliderImage![index],
              fit: BoxFit.fill,
            ),
          );
        },
        itemCount: storeInfo.sliderImage!.length,
        pagination: SwiperPagination(
            // 分页指示器
            alignment: Alignment.bottomCenter,
            // 位置 Alignment.bottomCenter 底部中间
            margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
            // 距离调整
            builder: DotSwiperPaginationBuilder(
                // 指示器构建
                space: ScreenUtil().setWidth(5),
                // 点之间的间隔
                size: ScreenUtil().setWidth(10),
                // 没选中时的大小
                activeSize: ScreenUtil().setWidth(12),
                // 选中时的大小
                color: Colors.black54,
                // 没选中时的颜色
                activeColor: Colors.white)),
        // 选中时的颜色
        // 页面控制器 左右翻页按钮
        scale: 0.95, //
      ),
    );
  }
}
